home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _B707DCF7DBF14A16928740DC9CD7B536 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.8 KB  |  79 lines

  1. --created by Kirill    
  2. --
  3. --    this entity has to be attached to a trigger
  4. --    it will add an impulse to a vehicle the player is in when triggering the trigger
  5. --    if player is not in the vehicle - does nothing
  6. --    Impulse is added in negative Y axis direction
  7.  
  8. Pusher = {
  9.     type = "Pusher",
  10.     Properties = {    
  11.         fImpulse = 10,
  12.         bEnabled = 1,
  13.         bOnce = 0,
  14.         },
  15.     Editor={
  16.         Model="Objects/Editor/T.cgf",
  17.     },
  18. }
  19.  
  20.  
  21. function Pusher:OnInit()
  22.  
  23.     self:OnReset();
  24.     
  25. end
  26.  
  27. -----------------------------------------------------------------------------
  28. function Pusher:OnReset( )
  29.  
  30.     self.isEnabled = self.Properties.bEnabled;
  31.     
  32. end
  33.  
  34.  
  35.  
  36. -----------------------------------------------------------------------------
  37. function Pusher:Event_Push( trigger,areaId )
  38.  
  39.     if( self.isEnabled == 0 ) then return end
  40. local player = trigger.Who;
  41.     if( not player ) then return end
  42. local theVehicle = player.theVehicle;    
  43.     if( not theVehicle ) then return end
  44.     if( not theVehicle.driverT ) then return end    
  45.     if( theVehicle.driverT.entity ~= player ) then return end
  46.  
  47.     theVehicle:AddImpulseObj( self:GetDirectionVector(), self.Properties.fImpulse);
  48.     
  49.     if(self.Properties.bOnce == 1) then
  50.         self.isEnabled = 0;
  51.     end    
  52. --System:Log("\001  pushing!!! ");
  53. end
  54.  
  55.  
  56. -----------------------------------------------------------------------------
  57. function Pusher:OnShutDown()
  58.  
  59. end
  60.  
  61.  
  62.  
  63. ----------------------------------------------------------------------------------------------------------------------------
  64. --
  65. function Pusher:Event_Enable( params )
  66.  
  67.     self.isEnabled = 1;
  68.  
  69. end
  70.  
  71. ----------------------------------------------------------------------------------------------------------------------------
  72. --
  73. function Pusher:Event_Disable( params )
  74.  
  75.     self.isEnabled = 0;
  76.  
  77. end
  78.  
  79.